/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.tom.social.dal.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Tom
 */
@Entity
@Table(name = "OwnerNick")
@NamedQueries({@NamedQuery(name = "OwnerNick.findAll", query = "SELECT o FROM OwnerNick o"),
	@NamedQuery(name = "OwnerNick.findByNick", query = "SELECT o FROM OwnerNick o WHERE o.nick = :nick")})
public class OwnerNick implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "id")
	private Integer id;
	@Basic(optional = false)
	@Column(name = "nick")
	private String nick;
	@JoinColumn(name = "owner_id", referencedColumnName = "id")
	@ManyToOne(optional = false, fetch=FetchType.LAZY)
	private Owner ownerId;

	public OwnerNick() {
	}

	public OwnerNick(String nick) {
		this.nick = nick;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public Owner getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(Owner ownerId) {
		this.ownerId = ownerId;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		if (!(object instanceof OwnerNick)) {
			return false;
		}
		OwnerNick other = (OwnerNick) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "pl.tom.social.dal.entity.OwnerNick[id=" + id + "]";
	}

}
